import { defineStore } from 'pinia';
import { ref } from "vue";
export const useCountStore = defineStore('count', () => {
	const count = ref([
		{product: [1, 1]},
		{product: [1, 1, 1]}
	]);
	const countChange = ref(false);
	// 初始请求数据后对count初始化
	function initCount(newData){
		count.value = newData;
	}
	function updateCount(newData, idxOfShop, idxOfProduct){
		count.value[idxOfShop].product[idxOfProduct] = newData;
		countChange.value = !countChange.value;
	}
	return { 
		count,
		countChange,
		initCount,
		updateCount
	};
});